package networkTraining.inspection;

import networkTraining.epoch.IEpochExecutor;
import neuralNetwork.INeuralNetwork;

public class TestingEpochErrorInspector implements IPostTestingEpochInspector, IPreInitializeInspector
{
	private StringBuilder info;

	public TestingEpochErrorInspector()
	{
		info = new StringBuilder();
	}

	@Override
	public void preInitializeInspect(INeuralNetwork neuralNetwork)
	{
		info.append("Network Layer Information:\n");
		for (int i = 0; i < neuralNetwork.getLayerCount(); i++)
		{
			info.append(String.format("\tLayer %d: %d nodes\n", i, neuralNetwork.getLayer(i).size()));
		}
		info.append("\n");

		info.append(String.format("%5s\t%24s\n", "Epoch", "RMS Error"));

	}

	@Override
	public void postTestingEpochInspect(IEpochExecutor epochExecutor)
	{
		info.append(String.format("%5d\t%24.17f\n", epochExecutor.getEpochIndex(), epochExecutor.getEpochRMSError()));
	}

	public String getInspectionInfo()
	{
		return info.toString();
	}

}
